 
<?php
//front
include_once("connect.php"); 
function grillehorraire($date){
$result=mysql_query("select heure from ap3_sp_rdv where dateRDV='".$date."' ");

    $occuper=array();
while($h=mysql_fetch_assoc($result))
    $occuper[]=$h['heure'];
echo "<table>";
	echo "<tr>"; 
		echo "<td class='colonneHeure'>";
			echo "<table class='heureRDV'><tr><td class='mms'>Matin</td></tr>";     
			for ($i=9; $i<=11;$i++){
				echo "<tr><td rowspan='5'>".$i."h</td>";
					for ($j=0; $j<4; $j++){
  						echo "<tr><td>".(15*$j)."</td><td><input type='radio' name='heure' value='".$i."h".(15*$j)."' ";
							foreach($occuper as $oc){
      							if (strcmp($oc,$i."h".(15*$j))==false)
									echo "disabled";
								}
						echo " /> </td></tr>";
						echo "</tr>";}
} 
echo "</table>";
echo "<table class='heureRDV'><td class='mms'>Midi</td></tr>";
for ($i=12; $i<=13;$i++)
{
echo "<tr><td rowspan='5'>".$i."h</td>";
for ($j=0; $j<4; $j++)
{  echo "<tr><td>".(15*$j)."</td><td><input type='radio' name='heure' value='".$i."h".(15*$j)."' ";
  foreach($occuper as $oc)
    {  if (strcmp($oc,$i."h".(15*$j))==false)
          echo "disabled";}
  echo " /> </td></tr>";
echo "</tr>";}
}
echo "</table>";
echo "</td>";
echo "<td class='colonneHeure'>";
echo "<table class='heureRDV'><td class='mms'>Aprés-midi</td></tr>"; 
for ($i=14; $i<19;$i++)
{
echo "<tr><td rowspan='5'>".$i."h</td>";
for ($j=0; $j<4; $j++)
{  echo "<tr ><td>".(15*$j)."</td><td><input type='radio' name='heure' value='".$i."h".(15*$j)."' ";
  foreach($occuper as $oc)
    {  if (strcmp($oc,$i."h".(15*$j))==false)
          echo "disabled";}
  echo " /> </td></tr>";
echo "</tr>";}
}
echo "</table>"; 
echo "</td>";
echo "</tr>";
echo "</table>";
}
function listesoins(){
$result=mysql_query("select * from ap3_sp_soins");
echo "<select name='soin'>";
while($soin=mysql_fetch_assoc($result))
    echo "<option value=".$soin['ID'].">".$soin['titre']."</option>";       
echo "</select>";
}
 
 ?> 
<div id='dureeSoins'>
</div> 
<div id='tableau'>
  <h2 id="corps">Prendre rendez-vous</h2>
  <br/>
  <br/>
  <?php if(isset($_SESSION["auth"]) && $_SESSION['auth'] != ""){?>
  <form action="prendre_rdv.php" method="post">
<?php
grillehorraire($_GET['date']);
    ?>
    <br/>
    <?php listesoins(); ?>
    <br/>
    <br/>
    <label>commentaire:  
    </label>
    <br/>
<textarea name="info" cols="50" rows="10"></textarea>
    <br/>
    <input type='hidden' name='auth' value=<?php echo $_SESSION["auth"];?>>
    <input type='hidden' name='date' value=<?php echo $_GET['date']; ?>>
    <input type="submit" value="Envoyer" />
  </form>
<?php
}
else{
echo"<span class='msgErreur'><p class='espace'>Vous devez être connecté.</p></span>";
  }?>
</div>